package com.hgd.security.evp.swagger.interceptor;

import org.springframework.stereotype.Component;
import org.springframework.web.method.HandlerMethod;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.lang.reflect.Method;

/**
 * @author ：尚村山夫
 * @date ：Created in 2019/8/13 21:28
 * @modified By：
 */
@Component
public class SwaggerInterceptor extends HandlerInterceptorAdapter {

    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
        throws Exception {
        HandlerMethod handlerMethod = (HandlerMethod) handler;
        Method method = handlerMethod.getMethod();
//        System.out.println(request.getRequestURI());
//        System.out.println("**************"+request.getRequestURL());
        return super.preHandle(request, response, handler);
    }

    @Override
    public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex)
        throws Exception {
        String requestURI = request.getRequestURI();
//        System.err.println("SwaggerInterceptor's requestURI::"+requestURI);
        super.afterCompletion(request, response, handler, ex);
    }
}
